/*
 *  pop3.h
 *
 *  Very simple POP3 email interface.  With SSL support.
 *
 * Copyright (c) 2006 Karlan Thomas Mitchell<karlanmitchell@gmail.com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, is prohibited except by
 * Karlan Thomas Mitchell.
 *
 * THIS SOFTWARE IS PROVIDED BY KARLAN THOMAS MITCHELL AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */






#ifndef __SIMPLE___POP3__H__
#define __SIMPLE___POP3__H__
#include "portable_socket.h"
#include <errno.h>
#include <stdio.h>

#ifndef PATH_MAX
#define PATH_MAX 255
#endif

#define POP3ERROR_CONNECTION -1
#define POP3ERROR_AUTH       -2
#define POP3ERROR_STAT       -3
#define POP3ERROR_RETR       -4
#define POP3ERROR_DEL        -5



struct st_pop3 {
struct st_psocket connection;

int connnection_status;

size_t messages;

int ssl;

char server[1024];
int short unsigned port;

char user[1024];
char password[1024];
};


int pop3_init(struct st_pop3 * pop3_data);
int pop3_reset(struct st_pop3 * pop3_data);
int pop3_stat(struct st_pop3 * pop3_data);
int pop3_del_email(struct st_pop3 * pop3_data, int email);
int pop3_load_email(struct st_pop3 * pop3_data, int email, char * email_buffer, size_t buf_len);
/*Called internally ONLY!  uses data filled in by pop3_connect*/
int pop3_internal_connect(struct st_pop3 * pop3_data);
int pop3_connect(struct st_pop3 * pop3_data, char * pop3server, char * user, char * password, int ssl);
int pop3_disconnect(struct st_pop3 * pop3_data);
int pop3_free(struct st_pop3 * pop3_data);

#endif 
